/*
 * Database helper class
 */
package org.dbdir.core.helper;

import java.sql.Timestamp;

/**
 *
 * @author thotheolh
 */
public class Database {

    private String dbAlias;
    private String dbPath;
    private String dbUsername;
    private String dbPassword;
    private Timestamp datetimeRegistered;

    public Database(String dbAlias, String dbPath, String dbUsername, String dbPassword, Timestamp datetimeRegistered) {
        this.setDbAlias(dbAlias);
        this.setDbPath(dbPath);
        this.setDbUsername(dbUsername);
        this.setDbPassword(dbPassword);
        this.setDatetimeResgistered(datetimeRegistered);
    }

    public Database() {
    }

    /**
     * @return the dbAlias
     */
    public String getDbAlias() {
        return dbAlias;
    }

    /**
     * @param dbAlias the dbAlias to set
     */
    public void setDbAlias(String dbAlias) {
        this.dbAlias = dbAlias;
    }

    /**
     * @return the dbPath
     */
    public String getDbPath() {
        return dbPath;
    }

    /**
     * @param dbPath the dbPath to set
     */
    public void setDbPath(String dbPath) {
        this.dbPath = dbPath;
    }

    /**
     * @return the dbUsername
     */
    public String getDbUsername() {
        return dbUsername;
    }

    /**
     * @param dbUsername the dbUsername to set
     */
    public void setDbUsername(String dbUsername) {
        this.dbUsername = dbUsername;
    }

    /**
     * @return the dbPassword
     */
    public String getDbPassword() {
        return dbPassword;
    }

    /**
     * @param dbPassword the dbPassword to set
     */
    public void setDbPassword(String dbPassword) {
        this.dbPassword = dbPassword;
    }

    /**
     * @return the datetimeResgistered
     */
    public Timestamp getDatetimeResgistered() {
        return datetimeRegistered;
    }

    /**
     * @param datetimeResgistered the datetimeResgistered to set
     */
    public void setDatetimeResgistered(Timestamp datetimeResgistered) {
        this.datetimeRegistered = datetimeResgistered;
    }

    public String getStrDatetimeResgistered() {
        if(datetimeRegistered!=null){
            String dtraw = datetimeRegistered.toString();
            String[] charArray = dtraw.split(" ");
            String value = charArray[0]+"&-"+charArray[1];
            return value;

        }else{
            return null;
        }
    }

    public String getString() {
        return "dbalias=" + this.getDbAlias() + " dbpath=" + this.getDbPath() + " dbusr=" + this.getDbUsername() + " dbpwd=" + this.getDbPassword() + " datetime=" + this.getStrDatetimeResgistered();
    }
}
